// 使用useEffect在挂载时发送请求


import React, { useEffect, useState } from 'react';
import request from 'utils/request';
export default function App() {
  
  const [list, setList] = useState([])
  async function loadData(){
    const res = await request({url:'/v1_0/channels'})
    setList(res.data.channels)
    console.log('list  ----->  ', list);
  }
  
  // 挂载时发送请求
// 🔔 useEffect接受一个同步函数，异步函数放Effect之外或之内
  useEffect(()=>{
    loadData()
  // eslint-disable-next-line react-hooks/exhaustive-deps
  },[])
  return <div></div>;
}